import datetime,time

def calculate_time(func):
    def wrap_func(*nkw,**kw):
        start=datetime.datetime.now()
        return_value=func(*nkw,**kw)
        end=datetime.datetime.now()
        print func.func_name,end-start
        return return_value
    return wrap_func

class c(object):
    @calculate_time
    def calculate(self,a):
        for i in range(2):
            print a
            time.sleep(1)
            for i in range(9999):
                i=0
cc=c()

cc.calculate('123')

